package com.BraveY.Demo04;

import java.util.ArrayList;
import java.util.Scanner;

public class Demo04 {

    public static void main(String[] args) {
        Scanner S = new Scanner(System.in);
        ArrayList<Student> list = new ArrayList<>();
        System.out.println("请输入您想录入学生信息的个数");
        int sum = S.nextInt();
        if (sum == 0) {
            System.out.println("你是来捣乱的把!");
        } else {
            for (int i = 0; i < sum; i++) {
                Student stu = getStudent(i);
                list.add(stu);
            }
            System.out.println();
            System.out.println("恭喜您!已录入成功!");
            System.out.println("您的学生信息为:");
            System.out.println();
            for (int i = 0; i < list.size(); i++) {
                Student stu = list.get(i);
                System.out.println("姓名:" + stu.getName() + "--年龄:" + stu.getAge());
            }
            System.out.println();
            System.out.println("感谢使用此系统!再见!");
/*            System.out.println();
            System.out.println("如果想对学生信息进行修改请按1,结束请安任意键");
            int num = S.nextInt();
            if (num == 1) {
                System.out.println("请输入您想修改的序号!");
                int setNum = S.nextInt();
                if(setNum> sum){
                    System.out.println("请输入小于" + sum +"的数");
                    setNum = S.nextInt();
                }else{
                    setNum = S.nextInt();
                }
            } else {
                System.out.println("感谢使用此系统!再见!");
            }*/
        }
    }

    public static Student getStudent(int i) {
        Scanner s = new Scanner(System.in);
        System.out.println("请输入第" + (i + 1) + "学生姓名：");
        String name = s.next();
        System.out.println("请输入第" + (i + 1) + "学生年龄：");
        int age = s.nextInt();
        Student stu = new Student(name, age);
        return stu;
    }

}
